package com.barnaul.area.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.barnaul.area.RootController;
import com.barnaul.area.domain.Register;
import com.barnaul.area.service.RegisterService;

@Controller
public class LoginController extends RootController {

	@Autowired
	private RegisterService registerService;

	@RequestMapping("/")
	public String home() {
		return "redirect:/welcome";
	}
	
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public String addContact(@ModelAttribute("register") Register register,
			BindingResult result) {

		registerService.addRegister(register);

		return "redirect:/";
	}

	@RequestMapping("/welcome")
	public String index() {
		return "/login/welcome";
	}
	
	@RequestMapping("/login")
	public String login() {
		return "/login/index";
	}
	
}
